﻿using MediatR;
using SystemWFH.API.Application.Command.WorkshopCommand;
using SystemWFH.Infrstructer.Interface;

namespace SystemWFH.API.Application.CommandHandlers.WorkshopCommandHandler
{
    public class WorkshopAddCommandHandler : IRequestHandler<WorkshopAddCommand, int>
    {
        private readonly IWorkshopRepository workshopRepository;
        public WorkshopAddCommandHandler(IWorkshopRepository workshopRepository)
        {
            this.workshopRepository = workshopRepository;
        }

        public async Task<int> Handle(WorkshopAddCommand request, CancellationToken cancellationToken)
        {
            return await workshopRepository.Add(new Domain.Workshop
            {
                workshopId = request.workshopId,
                workshopName = request.workshopName,
                workshopNo = request.workshopNo,
                workshopContact = request.workshopContact,
                workshopLeader = request.workshopLeader,
                workshopLocation = request.workshopLocation,
                workshopState = request.workshopState,
                AddName = "李思",
                AddTime = DateTime.Now.ToUniversalTime(),
            });
        }
    }
}
